package com.weiwei.diancan.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.weiwei.diancan.R;

import java.util.ArrayList;
import java.util.List;


/**
 * Conpany:成都欧品在线电子商务有限公司技术服务中心
 * Auther:戚定泉
 * Date: 2016/3/13
 * Effect: 会员支付方式
 */
public class IDBMemberPayStyleAdapter extends BaseAdapter {

    private Context context;
    private List<String> list = new ArrayList<>();
    private List<Integer> listImage = new ArrayList<>();

    public IDBMemberPayStyleAdapter(Context context) {
        this.context = context;
        list.add(context.getString(R.string.dialog_1));
        list.add(context.getString(R.string.dialog_2));
        list.add(context.getString(R.string.dialog_3));
        list.add(context.getString(R.string.dialog_4));

        listImage.add(R.mipmap.zuidan);
        listImage.add(R.mipmap.friends);
        listImage.add(R.mipmap.huanzuo);
        listImage.add(R.mipmap.beizhu);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View v, ViewGroup parent) {
        VH vh = null;
        if (v == null) {
            vh = new VH();
            v = LayoutInflater.from(context).inflate(R.layout.tband_item, null);
            vh.payName = (TextView) v.findViewById(R.id.pay_name);
            vh.icon_pay = (ImageView) v.findViewById(R.id.icon_pay);
            vh.pay_view = (LinearLayout) v.findViewById(R.id.pay_view);
            v.setTag(vh);
        } else {
            vh = (VH) v.getTag();
        }

        vh.payName.setText(list.get(position));
        vh.icon_pay.setImageResource(listImage.get(position));
        return v;
    }

    class VH {
        TextView payName;
        ImageView icon_pay;
        LinearLayout pay_view;
    }
}
